#pragma once 
#include <gtest/gtest.h>
#include "../ex_10/Chrono.h"
#include "../ex_10/Chrono.cpp"
using namespace Chrono;

class DateTest:public ::testing::Test
{
protected:
 virtual void SetUp() 
  {
	  dd2 = Date(2012, Date::feb, 29);
	  dd3 = Date(2012, Date::jan, 1);
  }

  // virtual void TearDown() {}

  vector<int> dim;
  Date dd1;
  Date dd2;
  Date dd3;
};

TEST_F(DateTest, DefaultCtorWork)
{
	EXPECT_EQ(2001, dd1.year());
	EXPECT_EQ(Date::jan, dd1.month());
	EXPECT_EQ(1, dd1.day());
}

TEST_F(DateTest, CtorWork)
{
	EXPECT_EQ(2012, dd2.year());
	EXPECT_EQ(Date::feb, dd2.month());
	EXPECT_EQ(29, dd2.day());
}

TEST_F(DateTest, AddDayWork)
{
	dd2.add_day(365);
	EXPECT_EQ(Date(2013,Date::feb,28), dd2);
}

TEST_F(DateTest, AddMonthWork)
{
	dd2.add_month(12);
	EXPECT_EQ(Date(2013,Date::mar,1), dd2);
}

TEST_F(DateTest, AddYearWork)
{
	dd2.add_year(1);
	EXPECT_EQ(Date(2013,Date::mar,1), dd2);
}


TEST_F(DateTest, DayInMonthWork)
{
	 dim.push_back(31);
	 dim.push_back(28);
	 dim.push_back(31);
	 dim.push_back(30);
	 dim.push_back(31);
	 dim.push_back(30);
	 dim.push_back(31);
	 dim.push_back(31);
	 dim.push_back(30);
	 dim.push_back(31);
	 dim.push_back(30);
	 dim.push_back(31);
	
	 for (int i=0; i<12; ++i)
	 {
		 EXPECT_EQ(dim[i], dd1.day_in_month());
		 dd1.add_month(1);
	 }
}

TEST_F(DateTest, DayOfWeakWork)
{
	int d=6;
	vector <int> days;
	for (int i=0; i < 20000; ++i)
	{
		days.push_back(d);	
		if (++d > 6) d = 0;
	}
	for (int i=0; i < days.size(); ++i)
	{
		EXPECT_EQ(days[i], day_of_week(dd3)) << i << '\t' << dd3;
		dd3.add_day(1);
	}
}



TEST_F(DateTest, NextSundayWork)
{
	
	for (int i=0; i < 20000; ++i)
	{
		dd3 = next_sunday(dd3);
		EXPECT_EQ(sunday, day_of_week(dd3));
	}
}


TEST_F(DateTest, NextWorkDayWork)
{
	
	for (int i=0; i < 20000; ++i)
	{
		dd3 = next_weekday(dd3);
		EXPECT_NE(sunday, day_of_week(dd3));
	}
}

